import React from 'react'
import { useState } from 'react'
import store from '../redux'
export default function Cart() {
  let [num,setNum] = useState(store.getState().num);
  store.subscribe(()=>{
    setNum(store.getState().num)
  })
  return (
    <div>
         <div>Cart---{num}</div>
         <button onClick={()=>{
            store.dispatch({
                type:"REDUCE",
                num:2
            })
         }}>--</button>
    </div>
  )
}
